#!/usr/bin/env node

const http = require('https'),
      log = console.log,
      cheerio = require('cheerio'),
      //url = require('url'),//对url进行解析
      addr = 'https://ke.sifou.com/free',
      baseURL = 'https://ke.sifou.com';

http.get(addr, (res)=>{
  let data = '';
  res.on('data', (chunck)=>{
    data += chunck;
  });

  res.on('end',()=>{
    let $ = cheerio.load(data);
    let course = $('body').find('h5.card-title>a');

    for(let i=0;i<course.length;i++){
      log($(course[i]).text());
      log(baseURL + $(course[i]).attr('href'));
      log();
    }
  });
});

